import Vue from 'vue';
import Router from 'vue-router';
import index from '@/components/portal-index/customer-portal/index.vue';
import Detial from '@/components/portal-index/product-detial/index.vue';
import Login from '@/components/admin-manager/login.vue';
import Admin from '@/components/admin-manager/index.vue';
import ProductCategory from '@/components/admin-manager/product-manager/product-category.vue'
import Brand from '@/components/admin-manager/product-manager/brand/product-brand.vue'
import ProductSpecGrop from "@/components/admin-manager/product-manager/product-spec-group.vue";
import ProductSpecParams from "@/components/admin-manager/product-manager/product-spec-params.vue";
import ProductList from "@/components/admin-manager/product-manager/product-list.vue";
import CmsCategoryList from "@/components/admin-manager/cms-index-manager/cms-category-list.vue";
import CmsContentList from "@/components/admin-manager/cms-index-manager/cms-content-list.vue";
import CartIndex from '@/components/portal-index/cart/index.vue';
import CustomerLogin from '@/components/portal-index/login/customer-login.vue';
import CustomerRegister from '@/components/portal-index/login/customer-register.vue';
import PreOrderInfo from '@/components/portal-index/order-info/pre-order-info.vue';
import AddToCartSuccess from "@/components/portal-index/product-detial/add-to-cart-success.vue";
import PayIndex from "@/components/portal-index/pay/pay-index.vue";
import WeiXinPay from "@/components/portal-index/pay/weixin-pay.vue";
import Orders from "@/components/portal-index/order-info/list-customer-orders.vue";
import UserCenter from "@/components/portal-index/user-center/user-center.vue";
import SearchIndex from "@/components/portal-index/search/search-index.vue";
import SysOrderList from "@/components/admin-manager/orders/sys-order-list.vue";
import SysCustomerList from "@/components/admin-manager/customer/customer-list.vue";
import SysUser from "@/components/admin-manager/user-role-manager/sys-user/sys-user.vue";
import SysPermission from "@/components/admin-manager/user-role-manager/sys-permission/sys-permission.vue";
import SysRole from "@/components/admin-manager/user-role-manager/sys-role/sys-role.vue";
import WorkFlowList from "@/components/admin-manager/user-role-manager/sys-work-flow/sys-work-flow.vue";
import SysMyApply from "@/components/admin-manager/user-role-manager/sys-my-apply/sys-my-apply.vue";
import MyTodoList from "@/components/admin-manager/user-role-manager/sys-my-todo/sys-my-todo.vue";
import NoPermissionPage from "@/components/admin-manager/user-role-manager/sys-permission/no-permission-tips.vue";
import Welcome from "@/components/admin-manager/welcome.vue";
Vue.use(Router);
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
let router = new Router({
    routes: [
        {
            path: '/',
            name: 'index',
            component: index,
            meta: {
                title: '云上商城(CLOUD.SHOP.COM)-正品低价、品质保障、配送及时、轻松购物!'
            }
        },
        {
            path: '/login',
            name: 'login',
            component: Login,
            meta: {
                title: '管理员登录'
            }
        },
        {
            path: '/customer/login',
            name: 'customerLogin',
            component: CustomerLogin,
            meta: {
                title: '个人登录'
            }
        },
        {
            path: '/customer/register',
            name: 'customerRegister',
            component: CustomerRegister,
            meta: {
                title: '个人注册'
            }
        },
        {
            path: '/search',
            name: 'search',
            component: SearchIndex,
            meta: {
                title: '商品搜索页'
            }
        },
        {
            path: '/detial',
            name: 'detial',
            component: Detial,
            meta: {
                title: '商品详情页'
            }
        },
        {
            path: '/add/cart/success',
            name: 'detial',
            component: AddToCartSuccess,
            meta: {
                title: '商品已成功加入购物车'
            }
        },
        {
            path: '/cart',
            name: 'Cart',
            component: CartIndex,
            meta: {
                title: '购物车'
            }
        },
        {
            path: '/preorder/info',
            name: 'preOrderInfo',
            component: PreOrderInfo,
            meta: {
                title: '订单结算页-JDX商城'
            }
        },
        {
            path: '/pay',
            name: 'pay',
            component: PayIndex,
            meta: {
                title: '收银台'
            }
        },
        {
            path: '/weixinpay',
            name: 'weixinpay',
            component: WeiXinPay,
            meta: {
                title: '微信支付'
            }
        },
        {
            path: '/customer/orders',
            name: 'orders',
            component: Orders,
            meta: {
                title: '订单列表'
            }
        },
        {
            path: '/customer/user/center',
            name: 'UserCenter',
            component: UserCenter,
            meta: {
                title: '我的账户'
            }
        },
        {
            path: '/admin',
            name: 'admin',
            component: Admin,
            meta: {
                title: '管理员首页'
            },
            children: [
                {
                    path: 'noPermissionPage',
                    component: NoPermissionPage,
                    meta: { keepAlive: false, title: "无权限提示" },
                },
                {
                    path: 'productSpecGrop',
                    component: ProductSpecGrop,
                    meta: { keepAlive: false, title: "规格参数组管理" },
                },
                {
                    path: 'productCategory',
                    component: ProductCategory,
                    meta: { keepAlive: false, title: "商品分类管理" },
                },
                {
                    path: 'brand',
                    component: Brand,
                    meta: { keepAlive: false, title: "品牌管理" },
                },
                {
                    path: 'productSpecParams',
                    component: ProductSpecParams,
                    meta: { keepAlive: false, title: "规格参数管理" },
                },
                {
                    path: 'productList',
                    component: ProductList,
                    meta: { keepAlive: false, title: "商品管理管理" },
                },
                {
                    path: 'cmsCategoryList',
                    component: CmsCategoryList,
                    meta: { keepAlive: false, title: "CMS分类管理" },
                },
                {
                    path: 'cmsContentList',
                    component: CmsContentList,
                    meta: { keepAlive: false, title: "CSM内容管理" },
                },
                {
                    path: 'sysOrderList',
                    component: SysOrderList,
                    meta: { keepAlive: false, title: "订单管理" },
                },
                {
                    path: 'sysCustomerList',
                    component: SysCustomerList,
                    meta: { keepAlive: false, title: "会员管理" },
                },
                {
                    path: 'sysUserList',
                    component: SysUser,
                    meta: { keepAlive: false, title: "用户管理" },
                },
                {
                    path: 'sysOperationRole',
                    component: SysRole,
                    meta: { keepAlive: false, title: "操作角色管理" },
                },
                {
                    path: 'sysOperationPermission',
                    component: SysPermission,
                    meta: { keepAlive: false, title: "操作权限管理" },
                },
                {
                    path: 'sysMenuRole',
                    component: SysRole,
                    meta: { keepAlive: false, title: "菜单角色管理" },
                },
                {
                    path: 'sysMeunPermission',
                    component: SysPermission,
                    meta: { keepAlive: false, title: "菜单权限管理" },
                },
                {
                    path: 'workFlowList',
                    component: WorkFlowList,
                    meta: { keepAlive: false, title: "工作流管理" },
                },
                {
                    path: 'myApplyList',
                    component: SysMyApply,
                    meta: { keepAlive: false, title: "我的申请" },
                },
                {
                    path: 'myTodoList',
                    component: MyTodoList,
                    meta: { keepAlive: false, title: "我的待办" },
                },
                {
                    path: 'welcome',
                    component: Welcome,
                    meta: { keepAlive: false, title: "我的待办" },
                }
            ]
        }
    ]
});
router.beforeEach((to, from, next) => {
    document.title = to.meta.title
    next()
});
export default router;
